package com.yu.mapper;

import com.yu.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * @Description: TODO
 * @Author : yu
 * Date : 3/21/2020 9:12 PM
 */
public class UserMapperImpl implements UserMapper{

    //现在我们的所有操作，都是用sqlsession来执行，而且简化了大量的步骤只需要取到sqlsessiontemplate就可以
    private SqlSessionTemplate sqlSession;

    public UserMapperImpl(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    public void setSqlSession(SqlSessionTemplate sqlSession) {
        this.sqlSession = sqlSession;
    }

    /**
     * @author: yu
     * @description: TODO
     * @date: 3/21/2020 9:14 PM
     * @param null
     * @return 
     */
    @Override
    public List<User> selectUser() {
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        return mapper.selectUser();
    }
}
